package com.ala4.oxcafe.controller;

import com.ala4.oxcafe.boot.annotation.Permission;
import com.ala4.oxcafe.boot.annotation.StatisticsUV;
import com.ala4.oxcafe.domain.R;
import com.ala4.oxcafe.entity.DecorationConfig;
import com.ala4.oxcafe.repository.DecorationConfigRepository;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 装修配置
 *
 * @author PING
 * @date 2025/8/16 18:59
 */
@RestController
@RequestMapping("/decoration-config")
@AllArgsConstructor
@Tag(name = "装修配置", description = "用于管理装修信息")
public class DecorationConfigController {

    private final DecorationConfigRepository decorationConfigRepository;

    @Operation(summary = "装修配置详情-公开接口")
    @GetMapping("/info")
    @StatisticsUV
    @Permission(permissionPublic = true)
    public R<DecorationConfig> info() {
        return R.ok(decorationConfigRepository.decorationConfig());
    }


    @Operation(summary = "保存装修配置")
    @PutMapping("/save")
    public R<DecorationConfig> update(@RequestBody @Validated DecorationConfig decorationConfig) {
        return R.ok(decorationConfigRepository.updateDecorationConfig(decorationConfig));
    }


}
